﻿using System;
using UnityEditor.Experimental.GraphView;
using UnityEngine;

namespace winS.UnityEditor.ProcessEditor
{
    public class NodeSearchEntry : NodeSearchItem
    {
        private readonly Type type;

        private SearchTreeEntry cache;

        protected readonly Type processType;

        public NodeSearchEntry(Type processType, string name, int level, Type type) : base(name, level)
        {
            this.type = type;
            this.processType = processType;
        }

        public SearchTreeEntry GetSearchTreeEntry(Type processType)
        {
            if (this.processType != null && this.processType != processType) return null;
            if (cache == null)
            {
                cache = new SearchTreeEntry(new GUIContent(name));
                cache.userData = type;
                cache.level = level;
            }
            return cache;
        }
    }
}